<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='文章管理',active='article'">
<header th:replace="back/header::headerFragment(${title},${active})"></header>
<head>
    <!--    <meta th:name="_csrf" th:content="${_csrf.token}"/>-->
    <meta/>
    <!-- 默认的header name是X-CSRF-TOKEN -->
    <!--    <meta th:name="_csrf_header" th:content="${_csrf.headerName}"/>-->
    <meta/>
</head>
<body class="fixed-left">
<div id="wrapper">
    <div th:replace="back/header::header-body"></div>
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="page-title">文章管理</h4>
                    </div>
                    <div class="col-md-12">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th width="35%">文章标题</th>
                                <th width="15%">发布时间</th>
                                <th>浏览量</th>
                                <th>所属分类</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <th:block th:each="article : ${pageInfo.list}">
                                <tr th:id="${article.id}">
                                    <td>
                                        <a th:href="@{'/articleId/'+${article.id}+'/commentPage/1/isHits/0'}"
                                           th:text="${article.title}" target="_blank"></a>
                                    </td>
                                    <td>
                                        <th:block th:text="${article.created}"/>
                                    </td>
                                    <td>
                                        <th:block th:text="${article.hits}"/>
                                    </td>
                                    <td>
                                        <th:block th:text="${article.categories}"/>
                                    </td>
                                    <td>
                                        <a th:href="@{'/admin/articleEdit/articledId/'+${article.id}}"
                                           class="btn btn-primary btn-sm waves-effect waves-light m-b-5">
                                            <i class="fa fa-edit"></i> <span>编辑</span></a>
                                        <!--                                        <a href="javascript:void(0)" th:onclick="'delArticle('+${article.id}+');'"-->
                                        <a th:onclick="|del(${article.id})|"
                                           class="btn btn-danger btn-sm waves-effect waves-light m-b-5">
                                            <i class="fa fa-trash-o"></i> <span>删除</span></a>
                                        <a class="btn btn-warning btn-sm waves-effect waves-light m-b-5"
                                           href="javascript:void(0)">
                                            <i class="fa fa-rocket"></i> <span>预览</span></a>
                                    </td>
                                </tr>
                            </th:block>

                            </tbody>
                        </table>
                        <!--                        <div th:replace="comm/paging :: pageAdminNav(${articles})"></div>-->

                        <div th:fragment="pageAdminNav(pageInfo)">
                            <div class="clearfix">
                                <ul class="pagination m-b-5 pull-right">
                                    <li th:if="${pageInfo.hasPreviousPage}">
                                        <a th:href="@{'/admin/articleList/pageNum/'+${pageInfo.prePage}}"
                                           aria-label="Previous">
                                            <i class="fa fa-angle-left"></i>&nbsp;上一页
                                        </a>
                                    </li>
                                    <th:block th:each="pageNum : ${pageInfo.navigatepageNums}">
                                        <!--                                        <li th:class="${nav==pageInfo.pageNum}?'active':''">-->
                                        <li>
                                            <a th:href="@{'/admin/articleList/pageNum/'+${pageNum}}" th:text="${pageNum}"></a>
                                        </li>
                                    </th:block>

                                    <th:block th:if="${pageInfo.hasNextPage}">
                                        <li>
                                            <a th:href="@{'/admin/articleList/pageNum/'+${pageInfo.nextPage}}"
                                               aria-label="Next">
                                                下一页&nbsp;<i class="fa fa-angle-right"></i>
                                            </a>
                                        </li>
                                    </th:block>

                                    <li><span th:text="'共'+${pageInfo.pages}+'页'"></span></li>
                                </ul>
                            </div>
                        </div>


                    </div>
                </div>
                <div th:replace="back/footer :: footer-content"></div>
            </div>
        </div>
    </div>
</div>
<div th:replace="back/footer :: footer"></div>
<script type="text/javascript">

    //billId 拿到传入的参数
    function del(articleId) {

        //点击该脚本（有好的删除脚本的提示信息）
        var b = confirm("你确定要删除该订单吗？");
        //返回的是一个布尔型的值
        if (b) {

            // console.log("/remove?billId=" + billId);

            //去指定好的请求地址 并且携带一个参数（前面拿到的参数）
            window.location.href = "/removeArticleByArticleId?articleId=" + articleId;
        } else {
            console.log("取消删除")
        }
    }

</script>
</body>
</html>